﻿using System;
using System.Collections.Generic;
using System.IO;
using System.Linq;
using System.Text;

namespace System.ServiceManager.Facade
{

    public interface IWorkFlowParameterObject
    {}

    [AttributeUsage(AttributeTargets.Property)]
    public class WorkFlowPropertyAttribute : Attribute
    {
        public WorkFlowPropertyAttribute()
        {
            PropertyName = string.Empty;
        }

        public WorkFlowPropertyAttribute(string propertyName)
        {
            PropertyName = propertyName;
        }

        public string PropertyName { get; set; }
        
    }


    public static class SCSMWorkflow 
    {

        public static string GetWorkFlowXml(string connectorName)
        {
            var path = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), string.Format("ConnectorData\\{0}.{1}" + connectorName,"workflow.xml"));
            if (!File.Exists(path))
                throw new InvalidOperationException(string.Format("{0} does not exist", path));

            var fileInfo = new FileInfo(path);
           
                var reader = fileInfo.OpenText();
                return reader.ReadToEnd();
           

        }

        public static string GetScheduleXml(string connectorName)
        {
            var path = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData), string.Format("ConnectorData\\{0}.{1}" + connectorName, "schedule.xml"));
          
            if (!File.Exists(path))
                throw new InvalidOperationException(string.Format("{0} does not exist", path));

            var fileInfo = new FileInfo(path);

            var reader = fileInfo.OpenText();
            return reader.ReadToEnd();


        }

        public static void AddWorkFlowType(string assemblyName, string workflowTypeName, IWorkFlowParameterObject workFlowPropertyObject)
        {

        }


      

    }

    
}
